package com.mall.dto;

import com.mall.entity.PmsSkuStock;
import com.mall.utils.SpDataJsonParser;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
public class FrontStockDto {
    @ApiModelProperty(value = "商品价格")
    private BigDecimal price;
    @ApiModelProperty(value = "商品库存")
    private int stock;
    @ApiModelProperty(value = "商品参数")
    private List<FrontCateAttributeDto> spData;

    public FrontStockDto(PmsSkuStock stock) {
        this.spData = SpDataJsonParser.parse(stock.getSpData());
        this.price = stock.getPrice();
        this.stock = stock.getStock();
    }
}
